<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of panel_model
 *
 * @author Neil
 */
class Panel_model extends CI_Model {
    /* public function paginas($params) {
      $sql = "call sp_paginas(?,?)";
      $query = $this->db->query($sql, $params);
      if ($query->num_rows() > 0) {
      foreach ($query->result() as $fila) :
      $data[] = $fila;
      endforeach;
      }else {
      $data = null;
      }
      return $data;
      } */

    public function menu($params = array(0, 0)) {
        $sql = "call sp_menus(?,?)";
        $query = $this->db->query($sql, $params);
        if ($query->num_rows() > 0) {
            foreach ($query->result() as $fila) :
                $data[] = $fila;
            endforeach;
        }else {
            $data = null;
        }
        return $data;
    }

    public function guardarPermisos($user, $pags) {
        $sql = "call sp_U_permisos(?,?,?)";
        try {
            foreach ($pags as $fila) {
                $params = array($user, $fila->idpag, $fila->per);
                $this->db->query($sql, $params);
            }
            return true;
        } catch (Exception $exc) {
            return false;
        }
    }

    public function lstEmpleados($cod) {
        $sql = "call sp_empleados(?)";
        $query = $this->db->query($sql, $cod);
        if ($query->num_rows() > 0) {
            foreach ($query->result() as $fila) :
                $data[] = $fila;
            endforeach;
        }else {
            $data = null;
        }
        return $data;
    }

    public function IU_Empleado($params) {
        $sql = "call sp_IU_empleado(?,?,?,?,?,?,?,?,?,?)";
        $this->db->query($sql, $params);
    }

}

?>
